/**
 * @description 该文件用于保存登录状态的账户和密码
 */

var my_account = {
  account: "",
  password: "",
  id: "",
  status: false,
};

const toLogin = (account, password, id) => {
  my_account.account = account;
  my_account.password = password;
  my_account.id = id;
  my_account.status = true;
  window.sessionStorage.setItem("my_account", JSON.stringify(my_account));
};

const toLogout = () => {
  my_account.account = "";
  my_account.password = "";
  my_account.id = "";
  my_account.status = false;
  window.sessionStorage.removeItem("my_account");
};

const getStatus = () => {
  return window.sessionStorage.getItem("my_account") ? true : false;
};

const getAccountInfo = () => {
  return JSON.parse(window.sessionStorage.getItem("my_account"));
}

export {
  toLogin,
  toLogout,
  getStatus,
  getAccountInfo,
}